/*
提交链接:https://leetcode.cn/problems/count-numbers-with-unique-digits/description/
357. 统计各位数字都不同的数字个数
赖德檀 2024/10/5
*/

class Solution {
public:
    int countNumbersWithUniqueDigits(int n) {
        if(n==0) return 1;
        int nums=10;
        for(int i=2;i<=n;i++)
        {
            int j=i-1;
            int sum=9;
            int t=9;
            while(j>0)
            {
                sum*=t;
                t--;
                j--;
            }
            nums+=sum;
        }
        return nums;
    }
};